package com.example.demo.entity;

import java.util.Arrays;
import java.util.Collection;

import javax.persistence.Entity;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

@Entity
public class Reader implements UserDetails {

	private static final long serialVersionUID = -5138204088487431981L;
	private String username;
	private String password;
	private String fullname;

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return Arrays.asList(new SimpleGrantedAuthority("READER"));//授予READER权限
	}

	@Override
	public String getPassword() {
		return this.password;
	}
	
	public void SetPassword(String password) {
		this.password = password;
	}

	@Override
	public String getUsername() {
		return this.username;
	}
	
	public void setUsername(String username) {
		this.username = username;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	@Override
	public boolean isAccountNonExpired() {
		return true;	//不过期
	}

	@Override
	public boolean isAccountNonLocked() {
		return true;	//不加锁
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return true;	
	}

	@Override
	public boolean isEnabled() {
		return true;	//不禁用
	}

}
